let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]

// 将每个元素都进行相同的操作
// 这里以乘以 2 演示
let arr1 = arr.map((value: number) => { return value * 2 })
console.log(arr1);

// 将所有元素合并成一个
let arr2 = arr.reduce((previousValue: number, currentValue: number) => { return previousValue + currentValue })
console.log(arr2);

// 过滤数组中的每一个元素，筛选出目标值
let arr3 = arr.filter((current: number) => { if (current % 2 == 1) return current })
console.log(arr3);
let arr4 = arr.filter((current: number) => { if (current % 2 == 0) return current })
console.log(arr4);


let array = [[1, 2, 3], [4, 5], [6, 7], [8, 9, 0], 11]
let result = []

// 将所有元素展开
result = array.flatMap((value: number | number[]) => { return value })
console.log(result);

// 处理每个元素
arr.forEach((value: number) => {
    console.log(value * 10)
})







